home *** CD-ROM | disk | FTP | other *** search
- // Fireworks Micfrosoft FrontPage HTML & javascript for single images & imagemaps.
- // Version 2.0 28JAN99
-
- // To export HTML without comments change the value of variable doComments to "false".
- var doComments=true;
-
- // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
- // include HTML and JavaScript in the exported file.
- function WRITE_HTML_COMMENT(str) {
- if (doComments) WRITE_HTML("<!--"+str+"-->\n");
- }
-
- function WRITE_JS_COMMENT(str) {
- if (doComments) WRITE_HTML("/* "+str+" */\n");
- }
-
- WRITE_HTML("\n");
- WRITE_HTML("<html>\n");
- WRITE_HTML("\n");
-
- WRITE_HTML("<head>\n");
- WRITE_HTML("\n");
-
- // Use Base Name from export dialog as document title.
- WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
- WRITE_HTML("\n");
-
- // Write Meta tags.
- WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
- var charSet = App.getPref("HtmlCharSet");
- if (charSet == "") charSet = "iso-8859-1";
- WRITE_HTML(charSet + "\">\n");
- WRITE_HTML("<meta name=\"description\" content=\"Fireworks Image Map\">\n");
- WRITE_HTML("\n");
-
- // Write HTML target and date created.
- var d = new Date();
- WRITE_HTML("<!-- Fireworks 2.0 FrontPage target. \n Created ", d, " -->\n");
- WRITE_HTML("\n");
-
- // Close head tag.
- WRITE_HTML("</head>\n");
- WRITE_HTML("\n");
-
- // Begin body tag. Set background color to Fireworks document canvas color.
- WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor, "\">\n");
- WRITE_HTML("\n");
-
- // Copying and pasting from the Fireworks-generated HTML file into an existing FrontPage
- // document while in Normal view can cause a loss of functionality. To help the user avoid this,
- // write this instructional text to display at the top of the document when viewed in FrontPage or in a browser.
- WRITE_HTML("<p>To place this Fireworks output in an existing HTML page, switch to the ");
- WRITE_HTML("HTML view and copy the HTML and JavaScript code beginning with the line:</p>\n");
- WRITE_HTML("<p>[!------------ BEGIN COPYING HERE ---------------]</p>\n");
- WRITE_HTML("<p>and continuing to the line:</p>\n");
- WRITE_HTML("<p>[!------------ STOP COPYING HERE ---------------]</p>\n");
- WRITE_HTML("<p>Paste the code into the body of your destination document in the HTML view.</p>\n");
- WRITE_HTML("<p>Note: This document and the destination document must be in the same folder.</p>\n");
- WRITE_HTML("<p> If you do not want to place this Fireworks output in an existing HTML page, delete this text.</p>\n");
- WRITE_HTML("\n");
-
- // Write comment for start of image map copy/paste section.
- WRITE_HTML_COMMENT("-- Copy the image and map code, and paste the data where ")
- WRITE_HTML_COMMENT("you want the image to appear in the destination document. --")
- WRITE_HTML("\n");
- WRITE_HTML_COMMENT("-------------------------- BEGIN COPYING HERE --------------------------")
- WRITE_HTML("\n");
-
- // Declare variables for processing Behaviors.
- var hasImagemap = false;
- var hasStatusMessages = false;
-
- var kActionStatusMessage = 1;
- var kActionSwapImage = 2;
- var kActionRadioGroup = 3;
-
- var kEventMouseOver = 0;
- var kEventOnClick = 1;
- var kEventMouseOut = 2;
-
- // Write a client-side imagemap
- if (exportDoc.clientMap) {
- var i = 0;
- while (i < imagemap.numberOfURLs) {
- hasImagemap = true; // at least 1 url in the imagemap.
- for (var j=0; j<imagemap[i].behaviors.numberOfBehaviors; j++) {
- var curBehavior = imagemap[i].behaviors[j];
- if (curBehavior.action == kActionStatusMessage) {
- hasStatusMessages = true;
- }
- }
- i++;
- }
- if (exportDoc.hasBackgroundLink) {
- hasImagemap = true;
- }
- }
-
- /* Note: In simple imagemaps using the template Imagemap.htt, the only available
- behavior is the status bar message. Otherwise, the Slices.htt template is used. */
- function ProcessBehavior(theCurBehaviors) {
- var gotJavascript = false;
- var overStat = false;
- var hitStat = false;
- var outStat = false;
- var eraseStatOnRestore = false;
- for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
- var curBehavior = theCurBehaviors[i];
- var curJavascript = "";
- var gotStat = false;
- if (curBehavior.action == kActionStatusMessage) {
- gotJavascript = true;
- gotStat = true;
- var statMsg = curBehavior.statusText;
- var restore = curBehavior.restoreOnMouseout;
- curJavascript += "dmim('" + statMsg + "');";
- if (restore) {
- eraseStatOnRestore = true;
- }
- } else {
- continue;
- }
- if (curBehavior.event == kEventMouseOver) {
- javaOver += curJavascript;
- if (gotStat) overStat = true;
- }
- if (curBehavior.event == kEventMouseOut) {
- javaOut += curJavascript;
- if (gotStat) outStat = true;
- }
- if (curBehavior.event == kEventOnClick) {
- javaClick += curJavascript;
- if (gotStat) hitStat = true;
- }
- }
- if (eraseStatOnRestore) {
- javaOut += "dmim('');" ;
- outStat = true;
- }
- var ret = "return document.MM_returnValue";
- if (overStat) javaOver += ret;
- if (outStat) javaOut += ret;
- if (hitStat) javaClick += ret;
- return(gotJavascript);
- }
-
- if (hasStatusMessages) {
-
- // The FrontPage webbot command "HTMLMarkup" specifies that code within it
- // will not be changed when the file is opened or saved in FrontPage.
- // Write the JavaScript inside this webbot tag to avoid any loss of functionality.
- write("<!--webbot bot=\"HTMLMarkup\" startspan -->\n");
- WRITE_HTML("\n");
-
- // write out the status message display function.
- WRITE_HTML("<script language=\"JavaScript\">\n");
- WRITE_HTML("<!-- hide this script from non-javascript-enabled browsers\n");
-
- // Begin Script. Hide Script from non-javascript-enabled browsers.
- WRITE_HTML("// Function that displays status bar messageS\n")
- WRITE_HTML("\n");
- WRITE_HTML("var showMsg = navigator.userAgent != \"Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)\";\n")
- WRITE_HTML("function dmim(msgStr) {\n")
- WRITE_HTML(" document.MM_returnValue = false;\n")
- WRITE_HTML(" if (showMsg) {\n")
- WRITE_HTML(" window.status = msgStr;\n")
- WRITE_HTML(" document.MM_returnValue = true;\n")
- WRITE_HTML(" }\n")
- WRITE_HTML("}\n")
-
- // Stop hiding script from non-javascript-enabled browsers. End script.
- WRITE_HTML("// stop hiding -->\n");
- WRITE_HTML("</script>\n");
-
- // Close FrontPage webbot tag.
- write("<!--webbot bot=\"HTMLMarkup\" endspan -->\n");
-
- }
-
- // If a server-side image map is being export, write comment on replacing file path.
- if (exportDoc.serverMap) {
- WRITE_HTML("<!-- ----------------------------------- NOTE ---------------------------------- --->\n");
- WRITE_HTML("<!-- Replace the text in the following HREF tag with the path to your map file's -->\n");
- WRITE_HTML("<!-- location on the server. The \"", exportDoc.pathBase, ".map\" file generated by Fireworks needs to be -->\n");
- WRITE_HTML("<!-- placed in a directory with a CGI Application capable of interpreting the Image -->\n");
- WRITE_HTML("<!-- Map information. If you are unsure about this, contact your web site -->\n");
- WRITE_HTML("<!-- administrator. -->\n");
- WRITE_HTML("\n");
-
- // Generate link to image map file.
- WRITE_HTML("<a href=\"path_to_map_file/", exportDoc.pathBase, ".map\">\n");
- }
-
- // Write image tag.
- WRITE_HTML("<img src=\"", exportDoc.filename,"\" ");
-
- // Determine width and height of image.
- WRITE_HTML("width=\"", exportDoc.width, "\" height=\"", exportDoc.height, "\"");
-
- // If document has hotspots name the image map.
- if (hasImagemap) {
- WRITE_HTML(" usemap=\"#", exportDoc.imagename, "\"")
- }
-
- // Declare and write alt text.
- var altText = exportDoc.altText;
-
- if (altText!="") {
- WRITE_HTML(" alt=\"", altText, "\"");
- }
-
- // If a server-side image map has been requested write ismap tag.
- if (exportDoc.serverMap) {
- WRITE_HTML(" ismap");
- }
-
- WRITE_HTML(" border=\"0\" >\n");
-
- if (exportDoc.serverMap) {
- WRITE_HTML("</a>\n");
- }
- WRITE_HTML("\n");
-
- // Write the image map inside of a HTMLMarkup webbot to allow
- // rollovers and status bar messages attached to hotspots without
- // having FrontPage write over them.
- if (hasImagemap) {
- write("<!--webbot bot=\"HTMLMarkup\" startspan -->\n");
-
- // Write the image map.
- WRITE_HTML("<map name=\"", exportDoc.imagename, "\">\n");
-
- var i = 0;
- while (i < imagemap.numberOfURLs) {
- var curImagemap = imagemap[i];
- var behaviors = curImagemap.behaviors;
- var javaOver = "";
- var javaOut = "";
- var javaClick = "";
- var gotJavascript = ProcessBehavior(behaviors);
-
- // Write the area tag with shape definitions.
- WRITE_HTML("<area shape=\"");
- WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
- WRITE_HTML("\" coords=\"");
- for (var j=0; j<curImagemap.numCoords; j++) {
- if (j>0) WRITE_HTML(",");
- // polygon has n coords.
- // rect has 2 coords, topLeft, and botomRight.
- // Circle has one coord; plus radius center.
- WRITE_HTML(curImagemap.xCoord(j), ",", curImagemap.yCoord(j));
- }
- if (curImagemap.shape == "circle") {
- // Write the radius for circle hotspots.
- WRITE_HTML(", ", curImagemap.radius);
- }
- WRITE_HTML("\"");
- var href = " href=\"#\"";
- if (curImagemap.hasHref) {
- href = " href=\"";
- href += curImagemap.href;
- href += "\"";
- if (curImagemap.hasTargetText) {
- href += " target=\"";
- href += curImagemap.targetText;
- href += "\"";
- }
- }
-
- // Write status bar message commands.
- if (javaOut != "") {
- WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
- }
- if (javaOver != "") {
- WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
- }
- if (javaClick != "") {
- WRITE_HTML(" onClick=\"", javaClick, "\" ");
- }
- WRITE_HTML(href);
-
- // Write alt text for hotspot.
- var altText = "";
- if (curImagemap.hasAltText) {
- altText = curImagemap.altText;
- } else {
- altText = exportDoc.altText;
- }
-
- if (altText!="") {
- WRITE_HTML(" title=\"", altText, "\"");
- WRITE_HTML(" alt=\"", altText, "\"");
- }
-
- WRITE_HTML(" >\n");
- i++;
- }
-
- // Write the image's default URL here.
- if (exportDoc.hasBackgroundLink && exportDoc.backgroundLink.href != "") {
- var curImagemap = exportDoc.backgroundLink;
- WRITE_HTML("<area shape=\"rectangle\" coords=\"0,0, ", exportDoc.width, ",", exportDoc.height, "\" ");
- WRITE_HTML("href=\"", curImagemap.href, "\"");
- if (curImagemap.hasTargetText) {
- WRITE_HTML("\n target=\"", curImagemap.targetText, "\"");
- }
- var altText = exportDoc.altText;
- if (altText!="") {
- WRITE_HTML(" title=\"", altText, "\"");
- WRITE_HTML(" alt=\"", altText, "\"");
- }
- WRITE_HTML(">\n");
- }
- WRITE_HTML("</map>\n")
- WRITE_HTML("\n");
-
- // Close HTMLMarkup webbot.
- write("<!--webbot bot=\"HTMLMarkup\" endspan -->\n");
-
- WRITE_HTML_COMMENT(" Image Map created with Macromedia Fireworks 2.0 ")
- }
-
- WRITE_HTML("\n");
-
- // End map copy/paste section.
- WRITE_HTML_COMMENT("----------------------------- STOP COPYING HERE ----------------------------")
-
- WRITE_HTML("\n");
- WRITE_HTML("</body>\n")
-
- WRITE_HTML("\n");
- WRITE_HTML("</html>\n")
-
-